from fastapi import APIRouter, HTTPException, Response
from fastapi.responses import StreamingResponse
import httpx
import os
from pydantic import BaseModel
from typing import List, Optional
import json
import logging

router = APIRouter(prefix="/gpt")

# 配置日志
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


class ChatRequest(BaseModel):
    model: Optional[str] = "deepseek-chat"
    temperature: Optional[float] = 0.7

# GET "127.0.0.1:8000/good_list"

@router.get("/goods_list")
async def polish_text_stream(request: ChatRequest):
    # 后端处理逻辑：增删改查
    return Response(
        {},
        media_type="text/event-stream",
        headers={
            "Cache-Control": "no-cache",
            "Connection": "keep-alive",
            "Content-Type": "text/event-stream; charset=utf-8",
            "Access-Control-Allow-Origin": "*",
        }
    )
    print(123)
